import request from '@/utils/request'

// 根据父节点查询
export function listByParent(useLocale, parentCode) {
  return request({
    url: '/system/area/listByParent',
    method: 'get',
    params: {
      useLocale,
      parentCode
    }
  })
}

//根据编码查询
export function getByCode(useLocale, code) {
  return request({
    url: '/system/area/getByCode',
    method: 'get',
    params: {
      useLocale,
      code
    }
  })
}

//根据编码查询各级区划
export function getEachLevelByCode(useLocale, code) {
  return request({
    url: '/system/area/getEachLevelByCode',
    method: 'get',
    params: {
      useLocale,
      code
    }
  })
}

//同步本地地址码
export function syncFromStandard() {
  return request({
    timeout: 0,
    url: '/system/area/syncFromStandard',
    method: 'get'
  })
}

//删除地区地址码
export function removeAreas(useLocale, code) {
  return request({
    url: '/system/area/removeAreas',
    method: 'post',
    params: {
      useLocale,
      code
    }
  })
}

//保存地区
export function saveArea(area) {
  return request({
    url: '/system/area/saveArea',
    method: 'post',
    params: area
  })
}

/**
 * 拖拽树
 * @param areas 拖拽集合
 */
export function dropArea(areas) {
  return request({
    url: '/system/area/dropArea',
    method: 'post',
    data: areas
  })
}

/**
 * 删除缓存
 */
export function cleanCaches() {
  return request({
    url: '/system/area/cleanCaches',
    method: 'delete'
  })
}
